version 14.0

log using "\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure3.log", replace
#delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      africancabinets_figure3.do                      *;
*       Date:           September 19, 2016                              *;
*       Author:         Molly Ariotti and Sona Golder                   *;
*       Purpose:      	Produce Figure 3 for CPS African portfolio      *;
*                       allocation paper.                               *;
* 	    Input File:     Africa.dta, Europe.dta                          *;
*       Output File:    figure3.log, coefplot.eps                       *;
*       Data Output:    none                                            *;             
*       Previous file:  none                                            *;
*       Machine:        laptop                           				*;
*     ****************************************************************  *;
*     ****************************************************************  *;

use "\Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa.dta"; 


*     ****************************************************************  *;
*       Drop African cabinets where there is no formateur coded.        *;
*     ****************************************************************  *;

drop if cabinetcode == 5;
drop if cabinetcode == 23;

*     ****************************************************************  *;
*       Add Europe data from Warwick and Druckman (2006)                *;
*     ****************************************************************  *;

append using "\Users\sgolder\Dropbox\Portfolio Allocation\replication\Europe.dta"; 

*     ****************************************************************  *;
*       Drop European cabinets where there is no formateur coded.       *;
*      (These are caseno 531, 532, 533, 534, 542,543, 617, 858, 859)    *;
*     ****************************************************************  *;

drop if code == 205097;
drop if code == 205098;
drop if code == 205099;
drop if code == 205100;
drop if code == 205108;
drop if code == 205109;
drop if code == 207130;
drop if code == 209184;
drop if code == 209185;

*     ****************************************************************  *;
*       Create regional, parliamentary dummy variables                  *;
*     ****************************************************************  *;

gen africa = . ;
replace africa = 1 if region==1;
replace africa = 0 if region==2;
replace africa = 0 if region==3;

gen europe = . ;
replace europe = 0 if region==1;
replace europe = 1 if region==2;
replace europe = 0 if region==3;

gen america = . ;
replace america = 0 if region==1;
replace america = 0 if region==2;
replace america = 1 if region==3;

gen parliamentary = 0;
replace parliamentary = 1 if presidential ==0;

*     ****************************************************************  *;
*       Build the component parts for the coefficient plot.             *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Formateur in Europe                                             *;
*     ****************************************************************  *;

regress portfolioshare seatshare formateur if africa==0, robust;

lincom formateur;

matrix eur = J(1,2,.);
matrix coln eur = estimate se;
matrix rown eur = "Europe Parliamentary";
matrix eur[1,1] = r(estimate);
matrix eur[1,2] = r(se);

*     ****************************************************************  *;
*       Formateur in Africa (parliamentary)                             *;
*     ****************************************************************  *;

regress portfolioshare seatshare formateur if parliamentary == 1 & africa==1, robust;

lincom formateur;

matrix afr = J(2,2,.);
matrix coln afr = estimate se;
matrix rown afr =  "Africa Parliamentary" "Africa Presidential";
matrix afr[1,1] = r(estimate);
matrix afr[1,2] = r(se);

*     ****************************************************************  *;
*       Formateur in Africa (presidential)                              *;
*     ****************************************************************  *;

regress portfolioshare seatshare formateur if parliamentary == 0 & africa==1, robust;

lincom formateur;

matrix afr[2,1] = r(estimate);
matrix afr[2,2] = r(se);

*     ****************************************************************  *;
*       Produce Figure 3                                                *;
*     ****************************************************************  *;

coefplot (matrix(eur[.,1]), se(eur[.,2]) offset(0) m(smcircle) mfcolor(eltblue*.4)mlc(eltblue) ciop(lcolor(eltblue)) label(Europe)) 
	(matrix(afr[.,1]), offset(0) se(afr[.,2]) m(smcircle) mfcolor(red*.25) mlc(red*1.2)	ciop(lcolor(red)) label(Africa)), 
	xline(0, lcolor(gs10) lpattern(dash)) legend(off)  
    scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white))
	xtitle("Formateur Bonus", height(7) size(3) ) ytitle("")
    xlabel(0 0.1 0.2 0.3 0.4, nogrid labsize(2.5))
	levels(95) coeflabels(Europe Parliamentary = "Europe Parliamentary" Africa Presidential ="Africa Presidential"
	Africa Parliamentary = "Africa Parliamentary" , labsize(3)  notick wrap(18)) grid(n) plotregion(style(none)) yscale(noline);

graph export "\Users\sgolder\Dropbox\Portfolio Allocation\replication\coefplot.eps", replace;


log close;
exit;

